home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************************
- * Copyright © 1992-1993 Mark Pilgrim *
- * *
- * This file is provided as is, and may be freely distributed unaltered. This *
- * message must accompany any copy of this file. This file may be used or *
- * modified for use for a non-commercial product provided that appropriate *
- * credit is given to the author named above. *
- * Commercial use of this source code is prohibited. *
- ******************************************************************************/
-
- #include "msg misc.h"
- #include "msg timing.h"
-
- #define BoxSize 10
- #define CorrectTime 4
-
- void FourCornerScroll(GrafPtr);
-
- /* Four scrolls in one, each confined to a section of the screen which includes
- the center and one side, and all four scrolls moving towards the center.
- Kinda slow on my Mac IIci in 8-bit; fine in 4-bit or fewer. */
-
- void FourCornerScroll(GrafPtr sourceGrafPtr)
- {
- int x;
- Rect theTopRect, topdest, theBottomRect, bottomdest;
- Rect theLeftRect, leftdest, theRightRect, rightdest;
- Rect topscrollsource, topscrolldest, bottomscrollsource, bottomscrolldest;
- Rect leftscrollsource, leftscrolldest, rightscrollsource, rightscrolldest;
- RgnHandle toprgn,bottomrgn,leftrgn,rightrgn;
- int cx,cy;
- int HBoxSize=BoxSize*MAIN_WINDOW_WIDTH/MAIN_WINDOW_HEIGHT;
-
- cx = MAIN_WINDOW_WIDTH / 2;
- cy = MAIN_WINDOW_HEIGHT / 2;
-
- toprgn=NewRgn();
- SetEmptyRgn(toprgn);
- MoveTo(0,0);
- OpenRgn(); /* top region */
- LineTo(MAIN_WINDOW_WIDTH,0);
- LineTo(cx,cy);
- LineTo(0,0);
- CloseRgn(toprgn);
-
- bottomrgn=NewRgn();
- SetEmptyRgn(bottomrgn);
- MoveTo(0,MAIN_WINDOW_HEIGHT);
- OpenRgn(); /* bottom region */
- LineTo(MAIN_WINDOW_WIDTH,MAIN_WINDOW_HEIGHT);
- LineTo(cx,cy);
- LineTo(0,MAIN_WINDOW_HEIGHT);
- CloseRgn(bottomrgn);
-
- leftrgn=NewRgn();
- SetEmptyRgn(leftrgn);
- MoveTo(0,0);
- OpenRgn(); /* left region */
- LineTo(0,MAIN_WINDOW_HEIGHT);
- LineTo(cx,cy);
- LineTo(0,0);
- CloseRgn(leftrgn);
-
- rightrgn=NewRgn();
- SetEmptyRgn(rightrgn);
- MoveTo(MAIN_WINDOW_WIDTH,0);
- OpenRgn(); /* right region */
- LineTo(MAIN_WINDOW_WIDTH,MAIN_WINDOW_HEIGHT);
- LineTo(cx,cy);
- LineTo(MAIN_WINDOW_WIDTH,0);
- CloseRgn(rightrgn);
-
- topscrollsource=bottomscrollsource=leftscrollsource=rightscrollsource=
- topdest=bottomdest=leftdest=rightdest=gMainWindow->portRect;
-
- topscrollsource.bottom-=cy+BoxSize;
- topscrolldest = topscrollsource;
- OffsetRect(&topscrolldest, 0, BoxSize); /* dest. strip for top scroll */
-
- topdest.bottom=BoxSize; /* dest. strip for new data on top */
-
- theTopRect.top=cy-BoxSize; /* source strip for new data on top */
- theTopRect.bottom=cy;
- theTopRect.left=0;
- theTopRect.right=MAIN_WINDOW_WIDTH;
-
- bottomscrollsource.top+=cy+BoxSize;
- bottomscrolldest=bottomscrollsource;
- OffsetRect(&bottomscrolldest, 0, -BoxSize);
-
- bottomdest.top=bottomdest.bottom-BoxSize;
-
- theBottomRect.top=cy;
- theBottomRect.left=0;
- theBottomRect.bottom=cy+BoxSize;
- theBottomRect.right=MAIN_WINDOW_WIDTH;
-
- leftscrollsource.right-=cx+HBoxSize;
- leftscrolldest=leftscrollsource;
- OffsetRect(&leftscrolldest,HBoxSize,0);
-
- leftdest.right=HBoxSize;
-
- theLeftRect.top=0;
- theLeftRect.bottom=MAIN_WINDOW_HEIGHT;
- theLeftRect.left=cx-HBoxSize;
- theLeftRect.right=cx;
-
- rightscrollsource.left+=cx+HBoxSize;
- rightscrolldest=rightscrollsource;
- OffsetRect(&rightscrolldest,-HBoxSize,0);
-
- rightdest.left=rightdest.right-HBoxSize;
-
- theRightRect.top=0;
- theRightRect.bottom=MAIN_WINDOW_HEIGHT;
- theRightRect.left=cx;
- theRightRect.right=cx+HBoxSize;
-
- /* for each section (top, bottom, left, right) we need to do the scroll part,
- which takes a section of the dest. window and moves it, then we need to copy
- in the new data from the source window */
- for(x = cy - BoxSize; x >= 0; x -= BoxSize)
- {
- StartTiming();
- CopyBits(&(gMainWindow->portBits), &(gMainWindow->portBits),
- &topscrollsource, &topscrolldest, 0, toprgn);
- CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
- &theTopRect, &topdest, 0, toprgn);
- theTopRect.bottom-=BoxSize;
- theTopRect.top-=BoxSize;
-
- CopyBits(&(gMainWindow->portBits), &(gMainWindow->portBits),
- &bottomscrollsource, &bottomscrolldest, 0, bottomrgn);
- CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
- &theBottomRect, &bottomdest, 0, bottomrgn);
- theBottomRect.top+=BoxSize;
- theBottomRect.bottom+=BoxSize;
-
- CopyBits(&(gMainWindow->portBits), &(gMainWindow->portBits),
- &leftscrollsource, &leftscrolldest, 0, leftrgn);
- CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
- &theLeftRect, &leftdest, 0, leftrgn);
- theLeftRect.left-=HBoxSize;
- theLeftRect.right-=HBoxSize;
-
- CopyBits(&(gMainWindow->portBits), &(gMainWindow->portBits),
- &rightscrollsource, &rightscrolldest, 0, rightrgn);
- CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
- &theRightRect, &rightdest, 0, rightrgn);
- theRightRect.left+=HBoxSize;
- theRightRect.right+=HBoxSize;
-
- TimeCorrection(CorrectTime);
- }
-
- theTopRect.top=theTopRect.left=0;
- theTopRect.bottom=MAIN_WINDOW_HEIGHT;
- theTopRect.right=MAIN_WINDOW_WIDTH;
- topdest=gMainWindow->portRect;
- CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
- &theTopRect, &topdest, 0, 0L); /* in case we missed any bits */
-
- DisposeRgn(toprgn);
- DisposeRgn(bottomrgn);
- DisposeRgn(leftrgn);
- DisposeRgn(rightrgn);
- }